Skip to contentSkip to conversation

Change in openvpn[master]: Implement Windows CA template match for Crypto-API selector

Openvpn-devel In review ssbssa (Code Review) 3 participants 12 messages May 28, 2024 – Jun 6, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1716917280000.Ia2c3e4c5c83ecccce1618c43b489dbe811de5351@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/621?usp=email

to review the following change.

Change subject: Implement Windows CA template match for Crypto-API selector
......................................................................

Implement Windows CA template match for Crypto-API selector

The certificate selection process for the Crypto API certificates is currently fixed to match on subject or identifier. Especially if certificates that are used for OpenVPN are managed by a Windows CA, it is appropriate to select the certificate to use by the template that it is generated from, especially on domain-joined clients which automatically acquire/renew the corresponding certificate.

The attached match implements the match on TMPL: with either a template name (which is looked up through CryptFindOIDInfo) or by specifying the OID of the template directly, which then is matched against the corresponding X509 extensions specifying the template that the certificate was generated from.

The logic requires to walk all certificates in the underlying store and to match the certificate extensions directly. The hook which is implemented in the certificate selection logic is generic to allow other Crypto-API certificate matches to also be implemented at some point in the future.

The logic to match the certificate template is taken from the implementation in the .NET core runtime, see Pal.Windows/FindPal.cs in in the implementation of System.Security.Cryptography.X509Certificates.

Change-Id Ia2c3e4c5c83ecccce1618c43b489dbe811de5351

---
M doc/man-sections/windows-options.rst
M src/openvpn/cryptoapi.c

2 files changed, 111 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/621/1

doc/man-sections/windows-options.rst +6 -0
index e87291f..3e66355 100644
@@ -55,6 +55,12 @@
 
      cryptoapicert "ISSUER:Sample CA"
 
+  To select a certificate based on a certificate's template name or
+  OID of the template:
+  ::
+
+     cryptoapicert "TMPL:1.3.6.1.4..."
+
   The first non-expired certificate found in the user's store or the
   machine store that matches the select-string is used.
 
src/openvpn/cryptoapi.c +105 -3

134 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/621?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia2c3e4c5c83ecccce1618c43b489dbe811de5351
Gerrit-Change-Number: 621
Gerrit-PatchSet: 1
Gerrit-Owner: ssbssa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

ssbssa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/621?usp=email )

Change subject: Implement Windows CA template match for Crypto-API selector
......................................................................

Patch Set 1:

(1 comment)

Patchset:

PS1:
This was originally sent by Heigo Wundram [1], and I'm reposting it (with some small changes) because I also need this.

Changes since v2:
- Added man page docu for cryptoapicert "TMPL:"
- Removed the if() of the first CryptFindOIDInfo call as was suggested.
- Removed the "V1 extension (Windows 2K and below)" part, or does openvpn still support Win2K?
- Call find_oid only if Objid doesn't match the template name.
- The code in find_certificate_in_store was a bit reordered, it should be easier to understand now.

[1] https://patchwork.openvpn.net/project/openvpn2/patch/[email protected].../

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/621?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia2c3e4c5c83ecccce1618c43b489dbe811de5351
Gerrit-Change-Number: 621
Gerrit-PatchSet: 1
Gerrit-Owner: ssbssa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 28 May 2024 17:43:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, ssbssa.

selvanair has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/621?usp=email )

Change subject: Implement Windows CA template match for Crypto-API selector
......................................................................

Patch Set 1:

(6 comments)

Patchset:

PS1:
I can't comment on the usefulness of this, but the changes look easy to maintain and clean, so a conditional feature-ACK from me.

At least one function call involves network search in the AD, a test report of what happens when no DC's are reachable would help. If that could cause a slow timeout, or error, we should document it. In typical setups DCs are often unreachable before the tunnel is up.

File doc/man-sections/windows-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/621/comment/98846a64_c997a4b3 :
PS1, Line 62: cryptoapicert "TMPL:1.3.6.1.4..."
Add an example where the template name is used instead of OID?

File src/openvpn/cryptoapi.c:

http://gerrit.openvpn.net/c/openvpn/+/621/comment/41d62b25_9fc645be :
PS1, Line 217: }
I think I said this in response to the original in 2021 as well: why separate into two calls like this? The use of the flag is to avoid network calls, but if we are anyway going to allow network access, its more efficient to allow it in the first place. I'm assuming the call will return quickly if a local search succeeds even if the flag is not there.

http://gerrit.openvpn.net/c/openvpn/+/621/comment/aa376a5e_4ae3dc25 :
PS1, Line 220: if (!info && fallback && groupid)
I see the only place this is called is with fallback=true, so we do not need that argument and can always fallback if groupid != 0.

http://gerrit.openvpn.net/c/openvpn/+/621/comment/9ee83cff_cbebf4f4 :
PS1, Line 277: * TMPL:<template name>
template name or OID ?

http://gerrit.openvpn.net/c/openvpn/+/621/comment/fcc24a46_78a084ec :
PS1, Line 314: find_type = CERT_FIND_ANY;
Shouldn't we use a more restrictive search with, say, CERT_FIND_HAS_PRIVATE_KEY? If there are multiple users on the client machine with certificates for each installed in the machine store, matching the template name alone could pick a certificate for which the user has no access to the private key and error out later.

This could also significantly reduce the number of certificates to walk through.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/621?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia2c3e4c5c83ecccce1618c43b489dbe811de5351
Gerrit-Change-Number: 621
Gerrit-PatchSet: 1
Gerrit-Owner: ssbssa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ssbssa <[email protected]...>
Gerrit-Comment-Date: Mon, 03 Jun 2024 03:04:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, ssbssa.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/621?usp=email

to look at the new patch set (#2).

Change subject: Implement Windows CA template match for Crypto-API selector
......................................................................

Implement Windows CA template match for Crypto-API selector

The certificate selection process for the Crypto API certificates is currently fixed to match on subject or identifier. Especially if certificates that are used for OpenVPN are managed by a Windows CA, it is appropriate to select the certificate to use by the template that it is generated from, especially on domain-joined clients which automatically acquire/renew the corresponding certificate.

The attached match implements the match on TMPL: with either a template name (which is looked up through CryptFindOIDInfo) or by specifying the OID of the template directly, which then is matched against the corresponding X509 extensions specifying the template that the certificate was generated from.

The logic requires to walk all certificates in the underlying store and to match the certificate extensions directly. The hook which is implemented in the certificate selection logic is generic to allow other Crypto-API certificate matches to also be implemented at some point in the future.

The logic to match the certificate template is taken from the implementation in the .NET core runtime, see Pal.Windows/FindPal.cs in in the implementation of System.Security.Cryptography.X509Certificates.

Change-Id Ia2c3e4c5c83ecccce1618c43b489dbe811de5351

---
M doc/man-sections/windows-options.rst
M src/openvpn/cryptoapi.c

2 files changed, 105 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/621/2

doc/man-sections/windows-options.rst +7 -0
index e87291f..1955869 100644
@@ -55,6 +55,13 @@
 
      cryptoapicert "ISSUER:Sample CA"
 
+  To select a certificate based on a certificate's template name or
+  OID of the template:
+  ::
+
+     cryptoapicert "TMPL:Name of Template"
+     cryptoapicert "TMPL:1.3.6.1.4..."
+
   The first non-expired certificate found in the user's store or the
   machine store that matches the select-string is used.
 
src/openvpn/cryptoapi.c +98 -3

127 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/621?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia2c3e4c5c83ecccce1618c43b489dbe811de5351
Gerrit-Change-Number: 621
Gerrit-PatchSet: 2
Gerrit-Owner: ssbssa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ssbssa <[email protected]...>
Gerrit-MessageType: newpatchset

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, selvanair.

ssbssa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/621?usp=email )

Change subject: Implement Windows CA template match for Crypto-API selector
......................................................................

Patch Set 2:

(6 comments)

Patchset:

PS2:
The new patch should resolve all comments.

File doc/man-sections/windows-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/621/comment/dea7be4c_cb1afe99 :
PS1, Line 62: cryptoapicert "TMPL:1.3.6.1.4..."

Quoted 1 line

Add an example where the template name is used instead of OID?

Done

File src/openvpn/cryptoapi.c:

http://gerrit.openvpn.net/c/openvpn/+/621/comment/63f95189_515a1777 :
PS1, Line 217: }

Quoted 1 line

I think I said this in response to the original in 2021 as well: why separate into two calls like th […]

Done

http://gerrit.openvpn.net/c/openvpn/+/621/comment/404e038e_7d02372b :
PS1, Line 220: if (!info && fallback && groupid)

Quoted 1 line

I see the only place this is called is with fallback=true, so we do not need that argument and can a […]

Done

http://gerrit.openvpn.net/c/openvpn/+/621/comment/f5b1a275_d56ff8fa :
PS1, Line 277: * TMPL:<template name>

Quoted 1 line

template name or OID ?

Done

http://gerrit.openvpn.net/c/openvpn/+/621/comment/79d659be_2fe54731 :
PS1, Line 314: find_type = CERT_FIND_ANY;

Quoted 1 line

Shouldn't we use a more restrictive search with, say, CERT_FIND_HAS_PRIVATE_KEY? If there are multip […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/621?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia2c3e4c5c83ecccce1618c43b489dbe811de5351
Gerrit-Change-Number: 621
Gerrit-PatchSet: 2
Gerrit-Owner: ssbssa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: selvanair <[email protected]...>
Gerrit-Comment-Date: Mon, 03 Jun 2024 14:35:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: selvanair <[email protected]...>
Gerrit-MessageType: comment

author Acked-by Selva Nair
#6 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, ssbssa.

selvanair has posted comments on this change by ssbssa. ( http://gerrit.openvpn.net/c/openvpn/+/621?usp=email )

Change subject: Implement Windows CA template match for Crypto-API selector
......................................................................

Patch Set 2: Code-Review+2

(2 comments)

Patchset:

PS2:
Thanks for the changes. Looks good to me now.
I have no setup to test this but I did confirm that "TMPL:" is recognized as a valid selector, and the code does iterate through certificates with private keys present.

File src/openvpn/cryptoapi.c:

http://gerrit.openvpn.net/c/openvpn/+/621/comment/66b4877b_503018f8?usp=email :
PS1, Line 220: if (!info && fallback && groupid)

Quoted 1 line

Done

nitpick: the comment is now a bit inaccurate -- "and fallback requested" is no longer required. May be edited at merge time.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/621?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia2c3e4c5c83ecccce1618c43b489dbe811de5351
Gerrit-Change-Number: 621
Gerrit-PatchSet: 2
Gerrit-Owner: ssbssa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ssbssa <[email protected]...>
Gerrit-Comment-Date: Thu, 06 Jun 2024 04:50:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: ssbssa <[email protected]...>
Comment-In-Reply-To: selvanair <[email protected]...>

#7 lore raw

PATCH v2 1/1 Implement Windows CA template match for Crypto-API selector

In reply to a message not in the archive

From: Heiko Wundram <[email protected]...>

The certificate selection process for the Crypto API certificates is currently fixed to match on subject or identifier. Especially if certificates that are used for OpenVPN are managed by a Windows CA, it is appropriate to select the certificate to use by the template that it is generated from, especially on domain-joined clients which automatically acquire/renew the corresponding certificate.

The attached match implements the match on TMPL: with either a template name (which is looked up through CryptFindOIDInfo) or by specifying the OID of the template directly, which then is matched against the corresponding X509 extensions specifying the template that the certificate was generated from.

The logic requires to walk all certificates in the underlying store and to match the certificate extensions directly. The hook which is implemented in the certificate selection logic is generic to allow other Crypto-API certificate matches to also be implemented at some point in the future.

The logic to match the certificate template is taken from the implementation in the .NET core runtime, see Pal.Windows/FindPal.cs in in the implementation of System.Security.Cryptography.X509Certificates.

Change-Id Ia2c3e4c5c83ecccce1618c43b489dbe811de5351

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/621
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):

doc/man-sections/windows-options.rst +7 -0
index e87291f..1955869 100644
@@ -55,6 +55,13 @@
 
      cryptoapicert "ISSUER:Sample CA"
 
+  To select a certificate based on a certificate's template name or
+  OID of the template:
+  ::
+
+     cryptoapicert "TMPL:Name of Template"
+     cryptoapicert "TMPL:1.3.6.1.4..."
+
   The first non-expired certificate found in the user's store or the
   machine store that matches the select-string is used.
 
src/openvpn/cryptoapi.c +98 -3

127 lines not on this page · raw message

#8 lore raw

[Openvpn-devel] [PATCH applied] Re: Implement Windows CA template match for Crypto-API selector

Thanks, Selva, for the review.

I have not tested this beyond "does it make GH actions happy", "does it build on the local mingw setup" (it does) and "does the code look generally safe wrt memory etc" (it does).

As instructed I have removed the "and fallback requested" part from the comment where "fallback" was removed from the code.

Your patch has been applied to the master branch.

commit 13ee7f902f18e27b981f8e440facd2e6515c6c83 (master)

Author: Heiko Wundram
Date:   Thu Jun 6 12:34:41 2024 +0200
     Implement Windows CA template match for Crypto-API selector

     Signed-off-by: Heiko Wundram <[email protected]...>
     Signed-off-by: Hannes Domani <[email protected]...>
     Acked-by: Selva Nair <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg28726.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#9 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Implement Windows CA template match for Crypto-API selector

Am Donnerstag, 6. Juni 2024 um 13:34:27 MESZ hat Gert Doering <[email protected]...> Folgendes geschrieben:

Quoted 15 lines

Thanks, Selva, for the review.

I have not tested this beyond "does it make GH actions happy", "does it build on the local mingw setup" (it does) and "does the code look generally safe wrt memory etc" (it does).

As instructed I have removed the "and fallback requested" part from the comment where "fallback" was removed from the code.

Your patch has been applied to the master branch.

commit 13ee7f902f18e27b981f8e440facd2e6515c6c83 (master)
Author: Heiko Wundram
Date:  Thu Jun 6 12:34:41 2024 +0200

Quoted 8 lines

     Implement Windows CA template match for Crypto-API selector

     Message-Id: <[email protected].....>
     URL: https://www.mail-archive.com/[email protected]/msg28726.html

Thanks for pushing this to master.

I wonder if it would be possible to merge this back to 2.6 as well, it's relatively isolated code, and 2.7 is still far-off (I think).

Regards
Hannes

#10 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Implement Windows CA template match for Crypto-API selector

In reply to Gert Doering

Hi,

Quoted 6 lines · Gert Doering

As instructed I have removed the "and fallback requested" part from the comment where "fallback" was removed from the code.

Your patch has been applied to the master branch.

commit 13ee7f902f18e27b981f8e440facd2e6515c6c83 (master)

... and to release/2.6, as this functionality is seen as useful, and the change is very non-intrusive. So it will be part of 2.6.11 "release planned in about 2 weeks".

commit dfbe11ac1842df400327be22951d0ba373534254 (release/2.6)

Author: Heiko Wundram <[email protected]...>
Date:   Thu Jun 6 12:34:41 2024 +0200

Implement Windows CA template match for Crypto-API selector

Compile-tested via GHA.

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#11 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by ssbssa. ( http://gerrit.openvpn.net/c/openvpn/+/621?usp=email )

Change subject: Implement Windows CA template match for Crypto-API selector
......................................................................

Implement Windows CA template match for Crypto-API selector

The certificate selection process for the Crypto API certificates is currently fixed to match on subject or identifier. Especially if certificates that are used for OpenVPN are managed by a Windows CA, it is appropriate to select the certificate to use by the template that it is generated from, especially on domain-joined clients which automatically acquire/renew the corresponding certificate.

The attached match implements the match on TMPL: with either a template name (which is looked up through CryptFindOIDInfo) or by specifying the OID of the template directly, which then is matched against the corresponding X509 extensions specifying the template that the certificate was generated from.

The logic requires to walk all certificates in the underlying store and to match the certificate extensions directly. The hook which is implemented in the certificate selection logic is generic to allow other Crypto-API certificate matches to also be implemented at some point in the future.

The logic to match the certificate template is taken from the implementation in the .NET core runtime, see Pal.Windows/FindPal.cs in in the implementation of System.Security.Cryptography.X509Certificates.

Change-Id Ia2c3e4c5c83ecccce1618c43b489dbe811de5351

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28726.html

---
M doc/man-sections/windows-options.rst
M src/openvpn/cryptoapi.c

2 files changed, 105 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/621/3

doc/man-sections/windows-options.rst +7 -0
index e87291f..1955869 100644
@@ -55,6 +55,13 @@
 
      cryptoapicert "ISSUER:Sample CA"
 
+  To select a certificate based on a certificate's template name or
+  OID of the template:
+  ::
+
+     cryptoapicert "TMPL:Name of Template"
+     cryptoapicert "TMPL:1.3.6.1.4..."
+
   The first non-expired certificate found in the user's store or the
   machine store that matches the select-string is used.
 
src/openvpn/cryptoapi.c +98 -3

127 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/621?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia2c3e4c5c83ecccce1618c43b489dbe811de5351
Gerrit-Change-Number: 621
Gerrit-PatchSet: 3
Gerrit-Owner: ssbssa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-MessageType: newpatchset

#12 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/621?usp=email )

Change subject: Implement Windows CA template match for Crypto-API selector
......................................................................

Implement Windows CA template match for Crypto-API selector

The certificate selection process for the Crypto API certificates is currently fixed to match on subject or identifier. Especially if certificates that are used for OpenVPN are managed by a Windows CA, it is appropriate to select the certificate to use by the template that it is generated from, especially on domain-joined clients which automatically acquire/renew the corresponding certificate.

The attached match implements the match on TMPL: with either a template name (which is looked up through CryptFindOIDInfo) or by specifying the OID of the template directly, which then is matched against the corresponding X509 extensions specifying the template that the certificate was generated from.

The logic requires to walk all certificates in the underlying store and to match the certificate extensions directly. The hook which is implemented in the certificate selection logic is generic to allow other Crypto-API certificate matches to also be implemented at some point in the future.

The logic to match the certificate template is taken from the implementation in the .NET core runtime, see Pal.Windows/FindPal.cs in in the implementation of System.Security.Cryptography.X509Certificates.

Change-Id Ia2c3e4c5c83ecccce1618c43b489dbe811de5351

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28726.html

---
M doc/man-sections/windows-options.rst
M src/openvpn/cryptoapi.c

2 files changed, 105 insertions(+), 3 deletions(-)
doc/man-sections/windows-options.rst +7 -0
index e87291f..1955869 100644
@@ -55,6 +55,13 @@
 
      cryptoapicert "ISSUER:Sample CA"
 
+  To select a certificate based on a certificate's template name or
+  OID of the template:
+  ::
+
+     cryptoapicert "TMPL:Name of Template"
+     cryptoapicert "TMPL:1.3.6.1.4..."
+
   The first non-expired certificate found in the user's store or the
   machine store that matches the select-string is used.
 
src/openvpn/cryptoapi.c +98 -3

127 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/621?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia2c3e4c5c83ecccce1618c43b489dbe811de5351
Gerrit-Change-Number: 621
Gerrit-PatchSet: 3
Gerrit-Owner: ssbssa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: selvanair <[email protected]...>
Gerrit-MessageType: merged